Skip to content

Conversation

downdawn
Copy link
Collaborator

@downdawn downdawn commented Aug 4, 2025

close #752

@wu-clan wu-clan self-requested a review August 4, 2025 15:30
@downdawn downdawn mentioned this pull request Aug 4, 2025
@downdawn downdawn changed the title feat: i18 support feat: i18n support Aug 5, 2025
Copy link
Member

@wu-clan wu-clan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

针对错误信息目前看起来不错,但功能需要进行打磨,请先不要合并,我会稍后更新这个

@wu-clan wu-clan marked this pull request as draft August 5, 2025 10:09
@wu-clan wu-clan changed the title feat: i18n support Add i18n support for error response message Aug 5, 2025
@downdawn
Copy link
Collaborator Author

downdawn commented Aug 5, 2025

针对错误信息目前看起来不错,但功能需要进行打磨,请先不要合并,我会稍后更新这个

这个pr只是一个参考,应该还不是最优解,比如翻译t方法缺少ide提示

@wu-clan wu-clan changed the title Add i18n support for error response message Add i18n support for response message Aug 14, 2025
@wu-clan wu-clan marked this pull request as ready for review August 14, 2025 14:39
@wu-clan
Copy link
Member

wu-clan commented Aug 14, 2025

@downdawn 我已经准备好了,如果没有问题,让我们合并它

wu-clan
wu-clan previously approved these changes Aug 14, 2025
@downdawn
Copy link
Collaborator Author

@downdawn 我已经准备好了,如果没有问题,让我们合并它

这个改版有点大,我们是否要考虑一下做分支,或者发起投票征求一下意见

@wu-clan
Copy link
Member

wu-clan commented Aug 14, 2025

这个 PR 目前是向后兼容的,理论上没有什么问题,我的想法是在本周的 v1.8.0 版本中提供

稍后我在 dis 上面发个投票看看

@wu-clan
Copy link
Member

wu-clan commented Aug 14, 2025

我们暂时先不要合并,等待社区反馈结果

@dk19930125
Copy link

大佬,我问下,这个国际化是后端国际化,还是前端国际化?

@wu-clan
Copy link
Member

wu-clan commented Aug 15, 2025

@dk19930125 针对后端的,不过用法跟前端几乎一样

这个就是为了同步前端国际化,前端在页面切换语言的同时,后端返回的响应消息也会同步切换语言

@dk19930125
Copy link

@dk19930125 针对后端的,不过用法跟前端几乎一样

这个就是为了同步前端国际化,前端在页面切换语言的同时,后端返回的响应消息也会同步切换语言

这样感觉不是很冗余吗

@wu-clan
Copy link
Member

wu-clan commented Aug 15, 2025

这样感觉不是很冗余吗

看场景,通常情况下,一个系统只会内置一种特定语言

如果你们是一个国内公司,但提供国际服务,这些国际用户并不懂中文,但他们使用你们系统遇到问题时,系统却提示了中文,前端的国际化只是针对页面展示的,并不会处理接口返回,此时后端 i18n 将发挥作用

如果你们只是一个普通的国内服务商,那显然 i18n 没有任何用处

@wu-clan
Copy link
Member

wu-clan commented Aug 15, 2025

@downdawn 我今晚会在 discord 提前结束投票

鉴于当前投票结果,我建议我们仅保留 i18n 最小实施,翻译部分将包括:error.captcha、pydantic.*、response.error、response.success、success.login.*,其余内容进行恢复

@downdawn
Copy link
Collaborator Author

@downdawn 我今晚会在 discord 提前结束投票

鉴于当前投票结果,我建议我们仅保留 i18n 最小实施,翻译部分将包括:error.captcha、pydantic.*、response.error、response.success、success.login.*,其余内容进行恢复

👌合理的

@wu-clan wu-clan merged commit cd48bb4 into master Aug 15, 2025
4 checks passed
@wu-clan wu-clan deleted the i18 branch August 15, 2025 11:57
RanY-Luck pushed a commit to RanY-Luck/fastapi_best_architecture that referenced this pull request Aug 21, 2025
* feat: i18n support

* Optimize i18n

* Update the locale in the code

* Update the zh-CN file

* Update the en-US file

* Update the reload filter

* Update locale success plugin value

* Fix lint

* Update pydantic error message translation

* Update to minimal implementation

* Fix minimal missing code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

重提国际化
3 participants